- Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathsource.cpp
32 lines (26 loc) · 1009 Bytes
/
source.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// <Snippet1>
#using <System.dll>
usingnamespaceSystem;
usingnamespaceSystem::Diagnostics;
usingnamespaceSystem::Threading;
intmain()
{
// Create the source, if it does not already exist.
if ( !EventLog::SourceExists( "MySource" ) )
{
//An event log source should not be created and immediately used.
//There is a latency time to enable the source, it should be created
//prior to executing the application that uses the source.
//Execute this sample a second time to use the new source.
EventLog::CreateEventSource( "MySource", "MyNewLog" );
Console::WriteLine( "CreatingEventSource" );
// The source is created. Exit the application to allow it to be registered.
return0;
}
// Create an EventLog instance and assign its source.
EventLog^ myLog = gcnew EventLog;
myLog->Source = "MySource";
// Write an informational entry to the event log.
myLog->WriteEntry( "Writing to event log." );
}
// </Snippet1>